import 'package:car_map/mode/navigation_model.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

///景点必体验标题分类
class WidgetAttractionsTypetitle extends StatefulWidget{

  final List<NavigationModel> navigationList;

  const WidgetAttractionsTypetitle({Key key, this.navigationList}) : super(key: key);

  @override
  _widgetAttractionsTypetitleState createState()=>_widgetAttractionsTypetitleState();

}

class _widgetAttractionsTypetitleState extends State<WidgetAttractionsTypetitle>{

  int indexCurend=0;

  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return Container(
      height:ScreenUtil().setHeight(80.0) ,
      child: ListView.builder(itemBuilder: (context,index){
        return itemList(index);
      },itemCount: widget.navigationList.length,shrinkWrap: true,scrollDirection: Axis.horizontal,),
    );
  }

  Widget itemList(int index){

    return InkWell(
      onTap: (){
        setState(() {
          indexCurend=index;
        });
      },
      child: Container(
        alignment: Alignment.center,
        padding: EdgeInsets.only(left: 8.0,right: 8.0),
        decoration: BoxDecoration(
            color: indexCurend==index?Colors.yellow:Colors.white,
            border: Border.all(color: Colors.black12,width: 0.5),
            borderRadius: BorderRadius.all(Radius.circular(5.0))
        ),
        margin: EdgeInsets.all(10.0),
        child: Text('${widget.navigationList[index].title}'),
      ),
    );
  }

}